package org.nch.videoLauncher.task;

import org.nch.videoLauncher.domain.Profile;
import org.nch.videoLauncher.repository.ProfileRepository;

import java.util.List;
import java.util.Collections;

/**
 * Created by IntelliJ IDEA.
 * User: bill
 * Date: Dec 13, 2008
 * Time: 2:06:52 PM
 * To change this template use File | Settings | File Templates.
 */
public class ProfileTask {

    public Profile getProfile(Integer id){

        ProfileRepository pfr = new ProfileRepository();
        return pfr.getById(id);
    }

    public Profile saveProfile(Profile pf){

        ProfileRepository pfr = new ProfileRepository();
        pfr.persist(pf);
        return pf;
    }

    public void deleteProfile(Profile pf){

        ProfileRepository pfr = new ProfileRepository();
        pfr.delete(pf);
    }

    public List<Profile> getAllProfiles(){
        ProfileRepository pfr = new ProfileRepository();
        List<Profile> theList = pfr.getAll();
        Collections.sort(theList);
        return theList;
    }

    public List<Profile> saveProfileList(List<Profile> Profiles){
        ProfileRepository pfr = new ProfileRepository();
        return pfr.persistAll(Profiles);
    }

    public void deleteProfileList(List<Profile> Profiles){
        ProfileRepository pfr = new ProfileRepository();
        for (Profile pf : Profiles){
            pfr.delete(pf);
        }
    }


}
